<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ page import="performReservation.SMMDBBean"%>
<%@ page import="java.sql.*"%>

<jsp:useBean id="per" scope="page" class="performReservation.Performace"/>
<jsp:useBean id="actor" scope="page" class="performReservation.Actor"/>
<% request.setCharacterEncoding("euc-kr");%>
<%!
	String name = null;
	String director = null;
	String language = null;
	String info = null;
	String releasedate = null;
	String category = null;
	String[] actors = null; 
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

</head>
<body>
	<%
		name = request.getParameter("name");
		director = request.getParameter("director");
		language = request.getParameter("language");
		info = request.getParameter("info");
		releasedate = request.getParameter("realeasedate");
		category = request.getParameter("category");
		actors = request.getParameterValues("actors").toString().split(":");
		if(name.equals("")||director.equals("")||language.equals("")||releasedate.equals("")||category.equals("")||actors.equals("")){
			out.println("you need to fill full all the blanks");
			
		}else{
			//insert performance
			per.setCategory(category);
			per.setDirector(director);
			per.setInfo(info);
			per.setLanguage(language);
			per.setName(name);
			per.setReleasdate(releasedate);
			SMMDBBean pProcess = SMMDBBean.getInstance();
			boolean b = pProcess.insertPerform(per);
			if(b){
				out.println(per.getName()+"  "+"has been added");
			}else{
				out.println("SQL error");
			}
			//insert actors
			for(int i = 0 ; i <actors.length;i++){
				actor.setName(actors[i]);
				
				pProcess.insertActor(actor);
			}
		}
	%>	
</body>
</html>